const express = require('express')
const app = express()

app.use((request, response, next) => {
  console.log('有人请求服务器了~~')
  next()
})

app.get('/test', (request, response) => {
  response.send('测试响应')
})

app.post('/login', (request, response) => {
  console.log('request-->query', request.query)
  console.log('request-->params', request.params)
  console.log('request-->body', request.body)
  response.send({ id: 1, userName: 'admin' })
})

app.listen(5000, (err) => {
  if (!err) console.log('服务器启动成功了~~，请求地址为：http://localhost:5000')
})
